package com.squirrel.michale;

/**
 * @author guanhao 观浩
 * @version 1.0.0.0
 * @createTime 2024/6/2 09:50
 * @company Michale Squirrel
 * @link
 * @description
 */
public class Day20240602_LeetCode002281 {

    public int totalStrength(int[] strength) {
        // 看了题解，这更是一道数学题，我用的暴力方法，第 64个测试用例超出时间限制，这道题以后有时间我在再消化，动态规划我需要多花点时间练题
        int result = 0;
        for (int i = 1; i <= strength.length; i++) {
            for (int j = 0; j <=strength.length-i; j++) {
                int min = Integer.MAX_VALUE;
                int sum = 0;
                for (int k = j; k <j+i&&k<strength.length; k++) {
                    int magic = strength[k];
                    if (magic < min) {
                        min = magic;
                    }
                    sum += magic;
                }
                int groupMagic = min * sum;
                System.out.println("result +=="+ min+ "*"+ sum);
                result += groupMagic;
                result %= 1000000007;
            }

        }
        return result%1000000007;
    }


    public static void main(String[] args) {
        int[] strength = new int[]{1, 3, 1, 2};
        Day20240602_LeetCode002281 leetCode002281 = new Day20240602_LeetCode002281();
        int i = leetCode002281.totalStrength(strength);
        System.out.println(i);

    }
}
